package com.whyx.project.openapi.bean;

import com.whyx.project.openapi.config.KafkaConsumerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.kafka.config.KafkaListenerContainerFactory;

@Configuration
public class GroupBean {

    @Autowired
    private KafkaConsumerConfig kafkaConsumerConfig;

    @Value("${handlecenter.kafka.consumer.GpsAlarm.id}")
    private String gpsAlarmId;
    @Value("${handlecenter.kafka.consumer.terminalCommon.id}")
    private String terminalCommonId;
    @Value("${handlecenter.kafka.consumer.requestData.id}")
    private String requestDataId;
    @Value("${handlecenter.kafka.consumer.sendResultRData.id}")
    private String sendResultRDataId;
    @Value("${handlecenter.kafka.consumer.takePhotoRightAway.id}")
    private String takePhotoRightAwayId;
    @Value("${handlecenter.kafka.consumer.deviceVersionReporting.id}")
    private String deviceVersionReportingId;
    @Value("${handlecenter.kafka.consumer.terminalQueryParamResponse.id}")
    private String terminalQueryParamResponseId;
    @Value("${handlecenter.kafka.consumer.QuerySpecifiedParametersResponse.id}")
    private String QuerySpecifiedParametersResponseId;
    @Value("${handlecenter.kafka.consumer.TextResponse.id}")
    private String TextResponseId;
    @Value("${handlecenter.kafka.consumer.TerminalQueryPropResponse.id}")
    private String TerminalQueryPropResponseId;
    @Value("${handlecenter.kafka.consumer.QueryPositionInfoResponse.id}")
    private String QueryPositionInfoResponseId;
    @Value("${handlecenter.kafka.consumer.UpgradeCompleteResponse.id}")
    private String UpgradeCompleteResponseId;
    @Value("${handlecenter.kafka.consumer.FileUploadResponse.id}")
    private String FileUploadResponseId;

    @Value("${handlecenter.kafka.consumer.MediaFileList.id}")
    private String MediaFileListId;
    @Value("${handlecenter.kafka.consumer.AutoCalibrationResponse.id}")
    private String AutoCalibrationResponseId;


    @Bean(name = "GpsAlarmFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordGpsAlarmFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(gpsAlarmId);
    }
    @Bean(name = "terminalCommonResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordterminalCommon() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(terminalCommonId);
    }
    @Bean(name = "sendResultRDataFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordSendResultRData() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(sendResultRDataId);
    }
    @Bean(name = "requestDataFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordrequestData() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(requestDataId);
    }

    @Bean(name = "takePhotoRightAwayResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordtakePhotoRightAway() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(takePhotoRightAwayId);
    }

    @Bean(name = "deviceVersionReportingResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordDeviceVersionReporting() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(deviceVersionReportingId);
    }

    //查询指定终端参数
    @Bean(name = "QuerySpecifiedParametersResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordQuerySpecifiedParameters() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(QuerySpecifiedParametersResponseId);
    }

    //查询终端参数
    @Bean(name = "TerminalQueryParamResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordTerminalQueryParam() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(terminalQueryParamResponseId);
    }



    @Bean(name = "TextResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordText() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(TextResponseId);
    }

    @Bean(name = "TerminalQueryPropResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordTerminalQueryProp() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(TerminalQueryPropResponseId);
    }

    @Bean(name = "QueryPositionInfoResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordQueryPositionInfoResponse() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(QueryPositionInfoResponseId);
    }

    @Bean(name = "UpgradeCompleteResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordUpgradeCompleteResponse() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(UpgradeCompleteResponseId);
    }

    @Bean(name = "FileUploadResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordFileUploadResponse() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(FileUploadResponseId);
    }

    @Bean(name = "MediaFileListFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordMediaFileListResponse() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(MediaFileListId);
    }

    @Bean(name = "AutoCalibrationResponseFactory")
    @Primary
    public KafkaListenerContainerFactory<?> batchRecordAutoCalibrationResponse() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(AutoCalibrationResponseId);
    }



}


